const express = require("express");
const morgan = require("morgan");
const router = require("./router.js");

const app = express();
// 挂载路由
app.use(router);
app.use(morgan("tiny"));

// 给路由限定访问前缀
app.use("/abc", router);

app.use((req, res, next) => {
  // 404的处理
});

// 在所有的中间件之后挂载错误处理中间件
app.use((err, res, rep, next) => {
  console.log("错误", err);
});

app.listen(3000, () => {
  console.log("server is running at http://localhost:3000");
});
